home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 October
/
EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso
/
Aminet
/
comm
/
mail
/
thor201.lha
/
THOR_2.0
/
thor.lha
/
rexx
/
UUDecode.thor
< prev
next >
Wrap
Text File
|
1995-05-15
|
6KB
|
226 lines
/* UUDecode.thor by Troels Walsted Hansen
** $VER: UUDecode.thor v2.20 (14.05.95)
**
** An ARexx script that uudecodes the file(s) contained in the
** message currently displayed in THOR. Can also be used from the
** commandline with one single argument, the name of the uu-message.
**
** Either of the following uudecoders may be used:
** · UUFast v1.25 by Jørn Halonen
** · uuOut v1.03 by Nicolas Dade.
** · UUxT v3.0 by Asher Feldman
** ...or you may define one for yourself.
**
** HISTORY
** ¯¯¯¯¯¯¯
** UUDecode.thor v2.00 (20.11.94)
** · This version is only for THOR v2.0 or higher.
** · A lot easier to adapt to other uudecoders and
** includes commandstrings for uuOut, UUFast and UUxT.
** · Finally fixed qoutes around downloadpath with spaces.
** (Thank you Sigbjørn Skjæret! :)
** · Doesn't require rexxsupport.library anymore.
** · adds comments to uudecoded files containing
** 'From <name> in <conf> on <bbsname>'.
**
** UUDecode.thor v2.05 (07.12.94)
** · adds filenotes to *all* files in the message
**
** UUDecode.thor v2.10 (19.03.95)
** · filenote adding is optional
** · specifies MSGNR instead of SAVEMESSAGE'ing CURRENT
** · may be used from the commandline
** · now shows errormsg from uudecoders if something went wrong
** (All suggested by Eirik Synnes)
**
** UUDecode.thor v2.15 (25.03.95)
** · now locks the gui whilst saving
** · improved find-filename-so-we-can-add-filenote code
**
** UUDecode.thor v2.16 (11.05.95)
** · forgot to delete a tmpfile
**
** UUDecode.thor v2.20 (14.05.95)
** · won't READBRMESSAGE if filenote adding is disabled
*/
/* some user variables. edit to your hearts content */
tmpdir = "T:" /* Work dir for the decoding */
uudecoder = "uuout" /* may be: uuout, uufast or uuxt */
filenotes = "no" /* Add filenotes? "yes" or "no" */
/* needs THOR and bbsread.library functions */
options results
options failat 31 /* otherwise the output window may pop up all the time */
p = address() || ' ' || show('P',,)
thorport = pos('THOR.',p)
if thorport > 0 then thorport = word(substr(p,thorport),1)
else
do
say 'No THOR port found!'
exit 10
end
if ~show('p', 'BBSREAD') then
do
address command
"run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
"WaitForPort BBSREAD"
end
/* the download dir needs to be obtained from THOR no matter what */
address(bbsread)
GETGLOBALDATA STEM GLOBALDATA
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
exit
end
endchar = right(GLOBALDATA.DNLOADPATH, 1)
if(endchar ~= ":" & endchar ~= "/") then GLOBALDATA.DNLOADPATH = GLOBALDATA.DNLOADPATH || '/'
/* if we got a filename on the commandline, half the script may be skipped */
parse arg msgfilename
if(msgfilename ~= '') then
do
filenotes = 'no'
signal commandline
end
/* no, we're not started from the commandline */
msgfilename = tmpdir || 'Message.uu'
/* lock the gui till we've saved the message */
address(thorport)
LOCKGUI
/* look for 'begin xxx filename' lines, so we can add a filenote later */
if(filenotes = "yes") then
do
address(thorport)
CURRENTMSG stem MSG
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'THOR.LASTERROR'"' BT '"_Ok"'
signal exit
end
address(bbsread)
READBRMESSAGE BBSNAME '"'MSG.BBSNAME'"' CONFNAME '"'MSG.CONFNAME'"' MSGNR MSG.MSGNR headstem HEADTAGS textstem TEXTTAGS
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'BBSREAD.LASTERROR'"' BT '"_Ok"'
signal exit
end
filenamecount = 1
do i=1 to TEXTTAGS.TEXT.COUNT
if(left(TEXTTAGS.TEXT.i, 5) = 'begin') then
do
realfilename.filenamecount = substr(TEXTTAGS.TEXT.i, wordindex(TEXTTAGS.TEXT.i, 3))
posi2 = 0
posi = pos(':', realfilename.filenamecount)
if(posi ~= 0) then posi2 = posi
posi = lastpos('/', realfilename.filenamecount)
if(posi ~= 0) then posi2 = posi
if(posi2 ~= 0) then realfilename.filenamecount = substr(realfilename.filenamecount, posi2+1)
filenamecount = filenamecount+1
end
end
end
/* save the message to a tmp file */
address(thorport)
SAVEMESSAGE CURRENT FILENAME msgfilename NOHEADER NOANSI
if(rc ~= 0) then
do
address(thorport)
REQUESTNOTIFY TEXT '"'THOR.LASTERROR'"' BT '"_Ok"'
signal exit
end
/* unlock the gui */
address(thorport)
UNLOCKGUI
/* label that specifies where to jump if we're started from the commandline */
commandline:
if ~exists(msgfilename) then
do
address(thorport)
REQUESTNOTIFY TEXT '"Message containing uuencoded file not found."' BT '"_Ok"'
exit
end
tmpfile = tmpdir || 'uudecoder.output'
select
when(uudecoder = 'uufast') then cmd = 'UUFast >' || tmpfile || ' ' || msgfilename || ' TO "' || GLOBALDATA.DNLOADPATH || '"'
when(uudecoder = 'uuout') then cmd = 'uuOut >' || tmpfile || ' ' || msgfilename || ' OUTPATH="' || GLOBALDATA.DNLOADPATH || '" USEBASENAME'
when(uudecoder = 'uuxt') then cmd = 'UUxT >' || tmpfile || ' x ' || msgfilename || ' dest=' || GLOBALDATA.DNLOADPATH
otherwise
do
address(thorport)
REQUESTNOTIFY TEXT '"UUDecoder not configured correctly."' BT '"_Ok"'
signal exit
end
end
address command cmd
if(rc ~= 0) then
do
call open(tmpfh, tmpfile, R)
errormsg = ''
do forever
str = readln(tmpfh)
if(str = '') then break
else errormsg = errormsg || '\n' || str
end
call close(tmpfh)
errormsg = 'UUDecoding did not succeed.' || errormsg
address(thorport)
REQUESTNOTIFY TEXT '"'errormsg'"' BT '"_Ok"'
end
else if(filenotes = "yes") then
do
do j=1 to (filenamecount-1)
address command 'filenote ' || '"' || GLOBALDATA.DNLOADPATH || realfilename.j || '"' || ' ' || '"' || 'From ' || HEADTAGS.FROMNAME || ' in ' || MSG.CONFNAME || ' on ' || MSG.BBSNAME || '"' || ' QUIET'
end
end
/* cleanup and exit */
exit:
address(thorport)
UNLOCKGUI
address command "delete >nil: "msgfilename
address command "delete >nil: "tmpfile
exit